package cn.zjxiliu.lib_login.utils;

import android.text.TextUtils;

import com.google.gson.Gson;

import cn.zjxiliu.lib_core.utils.SharedPreferencesUtils;
import cn.zjxiliu.lib_login.LoginSDK;
import cn.zjxiliu.lib_login.server.response.LoginResponse;

/**
 * Created by jessie on 2018/11/21.
 */

public class LoginInfoUtils {

    private static final String KEY_LOGIN_INFO = "key_login_info";

    public static void saveLoginInfo(LoginResponse loginResponse){
        SharedPreferencesUtils.putString(LoginSDK.getInstance().getContext(), KEY_LOGIN_INFO, loginResponse.toJSONStr());
    }

    public static LoginResponse getLoginInfo(){
        String result = SharedPreferencesUtils.getString(LoginSDK.getInstance().getContext(), KEY_LOGIN_INFO);
        if(TextUtils.isEmpty(result)){
            return null;
        }
        return new Gson().fromJson(result, LoginResponse.class);
    }




}
